<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <title>登录</title>
  <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  <meta name="author" content="Vincent Garreau" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="stylesheet" media="screen" href="lg/css/style.css">
  <link rel="stylesheet" type="text/css" href="lg/css/reset.css"/>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
</head>
<body>

<div id="particles-js">
	<form action="/entry" method="post" id="login-form">
		<div class="login">
			<div class="login-top">
				登录
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="lg/img/name.png"/></div>
				<div class="login-center-input">
					<input type="text" id="username" name="username" placeholder="请输入您的账号" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的账号'"/>
					<div class="login-center-input-text">账号</div>
				</div>
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="lg/img/password.png"/></div>
				<div class="login-center-input">
					<input type="password" id="password" name="password" placeholder="请输入您的密码" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
					<div class="login-center-input-text">密码</div>
				</div>
			</div>
			<div class="login-center clearfix">
<!--				<div><input type="checkbox" id="rememberMe" name="rememberMe" />记住密码</div>-->
				<div class="login-center-input">
				</div>
			</div>
			<div class="login-button" type="submit">
				登录
			</div>
		</div></form>
		<div class="sk-rotating-plane"></div>
</div>

<!-- scripts -->
<script src="lg/js/particles.min.js"></script>
<script src="lg/js/app.js"></script>

<script type="text/javascript">
	function check(){
		var Z_username = document.getElementById("username");
		var Z_password = document.getElementById("password");

		if(Z_username.value.length<1){
			alert("用户名为空！")
			return false
		}
		if(Z_password.value.length<1){
			alert("密码不能为空！")
			return false
		}
		return true;
	}
	$(".login-button").click(function () {

		if(check()) {
			/*$('#login-form').submit();*/

			  var  username = $('#username').val();
			 var  password = $('#password').val();
			 var  rememberMe = $('#rememberMe').val();

			$.ajax({
				type: 'POST',
				url: '/entry',
				data: {"username": username, "password": password, "rememberMe":rememberMe},
				/* dataType: 'json', */
				success: function (data) {
					if (data.code == "0") {
						// layer.msg('登录成功!', {icon: 1, time: 1000});
						location.href = "/index";
					}  else {
						layer.alert(data.msg, {icon: 4});
					}
				},
				error: function (data) {
					/* layer.alert("发生未知错误！", {icon:5}); */
					layer.alert('发生错误!', {icon: 2, time: 1000});
				},
			});
		}

	})


</script>

<!--<script type="text/javascript">
	function hasClass(elem, cls) {
	  cls = cls || '';
	  if (cls.replace(/\s/g, '').length == 0) return false; //当cls没有参数时，返回false
	  return new RegExp(' ' + cls + ' ').test(' ' + elem.className + ' ');
	}
	 
	function addClass(ele, cls) {
	  if (!hasClass(ele, cls)) {
	    ele.className = ele.className == '' ? cls : ele.className + ' ' + cls;
	  }
	}
	 
	function removeClass(ele, cls) {
	  if (hasClass(ele, cls)) {
	    var newClass = ' ' + ele.className.replace(/[\t\r\n]/g, '') + ' ';
	    while (newClass.indexOf(' ' + cls + ' ') >= 0) {
	      newClass = newClass.replace(' ' + cls + ' ', ' ');
	    }
	    ele.className = newClass.replace(/^\s+|\s+$/g, '');
	  }
	}
		document.querySelector(".login-button").onclick = function(){
				addClass(document.querySelector(".login"), "active")
				setTimeout(function(){
					addClass(document.querySelector(".sk-rotating-plane"), "active")
					document.querySelector(".login").style.display = "none"
				},800)
				setTimeout(function(){
					removeClass(document.querySelector(".login"), "active")
					removeClass(document.querySelector(".sk-rotating-plane"), "active")
					document.querySelector(".login").style.display = "block"
					alert("登录成功")
					
				},5000)
		}
</script>-->
<div style="text-align:center;">

</div>
</body>
</html>